package com.homework.ch02;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/23
 * @Description:
 */
public class Test09 {
    public static void main(String[] args) {
        Stream<Integer> stream= Stream.of(1,2,3,4,5);
       /* Optional<Integer> max=stream.max((o1,o2)->o1-o2);
        System.out.println(max.get());*/
        //Optional<Integer> max=stream.max(Integer::compare);
        //System.out.println(max.get());
       /* Optional<Integer> min=stream.min(Integer::compare);
        System.out.println(min.get());*/
        //System.out.println(stream.findFirst());
        //System.out.println(stream.findAny());

        Stream<Integer> stream2=stream.limit(1);
        System.out.println(stream2.count());//中间操作遇到终端操作才会终止
    }
}
